let todoLoveMixin = {
	methods:{
		async clickLove(item){
			console.log(item,item.id)
			//是否处于登陆状态
			if(!this.loginState){
				this.$refs.login.openLogin()
				return
			}
			// 动态点赞
			if (item.has_like) {
				--item.like_count;
				item.has_like = false;
				try{
					await this.$u.api.unlikeThisFeed({
						id: item.id,
					});
				}catch(e){
					//TODO handle the exception
					uni.showToast({
						title: "取消点赞",
						icon: "success",
						duration: 1000,
					});
				}
				uni.showToast({
					title: "取消点赞",
					icon: "success",
					duration: 1000,
				});
				
				
			} else {
				++item.like_count;
				item.has_like = true;
				try{
					await this.$u.api.likeThisFeed({
						id: item.id,
					});
				}catch(e){
					//TODO handle the exception
					uni.showToast({
						title: "点赞成功",
						icon: "success",
						duration: 1000,
					});
				}
				
				uni.showToast({
					title: "点赞成功",
					icon: "success",
					duration: 1000,
				});
			}
			uni.$emit('indexFeedLoveChange',item)
			uni.$emit('myFeedLoveChange',item)
		}
	}
}

export default todoLoveMixin